import { IsNumber, IsArray, ValidateNested, IsBoolean } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';

class SubMatchInfoDto {
  @ApiProperty({ description: '子比赛序号' })
  @IsNumber()
  subMatchOrder: number;

  @ApiProperty({ description: '选手 ID' })
  @IsNumber()
  playerId: number;

  @ApiProperty({ description: '第二个选手 ID' })
  @IsNumber()
  player2Id: number;

  @ApiProperty({ description: '是否是轮空' })
  @IsBoolean()
  isByePlayer: boolean = false; // 是否轮空
}

class TeamInfoDto {
  @ApiProperty({ description: '团队选手 ID' })
  @IsNumber()
  teamPlayerId: number;

  @ApiProperty({
    type: [SubMatchInfoDto],
    description: '子比赛信息数组',
  })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => SubMatchInfoDto)
  subMatchInfos: Array<SubMatchInfoDto>;
}

export class BindTeamPlayerE2PDto {
  @ApiProperty({ description: '阶段 ID' })
  @IsNumber()
  stageId: number;

  @ApiProperty({
    type: [TeamInfoDto],
    description: '团队信息数组',
  })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => TeamInfoDto)
  teamInfos: Array<TeamInfoDto>;
}
